import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;

//���������蹂� ���硫�
public class GUI_store extends JPanel implements ActionListener{
	ImageButton btStart;
	ImageButton btRank;
	ImageButton btHelp;

	
	public GUI_store(){
		setLayout(null);
		
		GUI_storeBar StoreBar = new GUI_storeBar();
		StoreBar.setBounds(0, 0, 800, 50);
		add(StoreBar);
	
		GUI_storeContext Context = new GUI_storeContext();
		Context.setBounds(0, 50, 800, 420);
		add(Context);	
		
	}
	
	public void actionPerformed(ActionEvent ae){
		Main.Navi.con.removeAll();
		
		GUI_menu Menu = new GUI_menu();
		Menu.setBounds(0, 0, 800, 500);
		Main.Navi.con.add(Menu);
		
		Main.Navi.con.validate();
	}
}
	

class GUI_storeBar extends JPanel implements ActionListener{
	Image img = null;
	
	public GUI_storeBar(){
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		img = kit.getImage("images/bar.jpg");
		
		setLayout(null);

		JLabel lb = new JLabel("상점 정보");
		lb.setBounds(310, 10, 200, 30);
		lb.setForeground(Color.white);
		lb.setFont(new Font("bold",Font.BOLD,30));
		add(lb);
		
		Image btimg_menu[] = new Image[4];
		btimg_menu[0] = kit.getImage("images/bt_menu.jpg"); 
		btimg_menu[1] = kit.getImage("images/bt_menu.jpg"); 
		btimg_menu[2] = kit.getImage("images/bt_menu.jpg"); 
		btimg_menu[3] = kit.getImage("images/bt_menu.jpg"); 
		
		ImageButton bt_menu = new ImageButton(btimg_menu);
		bt_menu.setBounds(700, 0, 70, 100);
		bt_menu.addActionListener(this);
		add(bt_menu);
				
	}
	protected void paintComponent(Graphics g){ 
		g.drawImage(img, 0, 0, 800, 100, this); 
	}
	public void actionPerformed(ActionEvent ae){
		Main.Navi.con.removeAll();
		
		GUI_menu Menu = new GUI_menu();
		Menu.setBounds(0, 0, 800, 100);
		Main.Navi.con.add(Menu);
		
		Main.Navi.con.validate();
	}
}
	


class GUI_storeContext extends JPanel implements ActionListener{
	
	ImageButton bt_rest;
	ImageButton bt_cafe;
	ImageButton bt_hos;
	ImageButton bt_bank;
	ImageButton bt_park;
	ImageButton bt_oil;
	ImageButton bt_movie;
	ImageButton bt_search;
	
	public GUI_storeContext(){
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		setLayout(null);
		setBackground(Color.darkGray);
		
		Image btimg_rest[] = new Image[4];
		btimg_rest[0] = kit.getImage("images/bt_rest.jpg"); 
		btimg_rest[1] = kit.getImage("images/bt_rest.jpg"); 
		btimg_rest[2] = kit.getImage("images/bt_rest1.jpg"); 
		btimg_rest[3] = kit.getImage("images/bt_rest.jpg"); 
		
		Image btimg_cafe[] = new Image[4];
		btimg_cafe[0] = kit.getImage("images/bt_cafe.jpg"); 
		btimg_cafe[1] = kit.getImage("images/bt_cafe.jpg"); 
		btimg_cafe[2] = kit.getImage("images/bt_cafe1.jpg"); 
		btimg_cafe[3] = kit.getImage("images/bt_cafe.jpg"); 
		
		Image btimg_hos[] = new Image[4];
		btimg_hos[0] = kit.getImage("images/bt_hos.jpg"); 
		btimg_hos[1] = kit.getImage("images/bt_hos.jpg"); 
		btimg_hos[2] = kit.getImage("images/bt_hos1.jpg"); 
		btimg_hos[3] = kit.getImage("images/bt_hos.jpg"); 
		
		Image btimg_bank[] = new Image[4];
		btimg_bank[0] = kit.getImage("images/bt_bank.jpg"); 
		btimg_bank[1] = kit.getImage("images/bt_bank.jpg"); 
		btimg_bank[2] = kit.getImage("images/bt_bank1.jpg"); 
		btimg_bank[3] = kit.getImage("images/bt_bank.jpg"); 
		
		Image btimg_park[] = new Image[4];
		btimg_park[0] = kit.getImage("images/bt_park.jpg"); 
		btimg_park[1] = kit.getImage("images/bt_park.jpg"); 
		btimg_park[2] = kit.getImage("images/bt_park1.jpg"); 
		btimg_park[3] = kit.getImage("images/bt_park.jpg"); 
		
		Image btimg_oil[] = new Image[4];
		btimg_oil[0] = kit.getImage("images/bt_oil.jpg"); 
		btimg_oil[1] = kit.getImage("images/bt_oil.jpg"); 
		btimg_oil[2] = kit.getImage("images/bt_oil1.jpg"); 
		btimg_oil[3] = kit.getImage("images/bt_oil.jpg"); 
		
		Image btimg_movie[] = new Image[4];
		btimg_movie[0] = kit.getImage("images/bt_movie.jpg"); 
		btimg_movie[1] = kit.getImage("images/bt_movie.jpg"); 
		btimg_movie[2] = kit.getImage("images/bt_movie1.jpg"); 
		btimg_movie[3] = kit.getImage("images/bt_movie.jpg"); 
		
		Image btimg_search[] = new Image[4];
		btimg_search[0] = kit.getImage("images/bt_search2.jpg"); 
		btimg_search[1] = kit.getImage("images/bt_search2.jpg"); 
		btimg_search[2] = kit.getImage("images/bt_search1.jpg"); 
		btimg_search[3] = kit.getImage("images/bt_search2.jpg"); 
		
		bt_rest = new ImageButton(btimg_rest);
		bt_cafe = new ImageButton(btimg_cafe);
		bt_hos = new ImageButton(btimg_hos);
		bt_bank = new ImageButton(btimg_bank);
		bt_oil = new ImageButton(btimg_oil);
		bt_park = new ImageButton(btimg_park);
		bt_movie = new ImageButton(btimg_movie);
		bt_search = new ImageButton(btimg_search);
		
		
		bt_rest.setBounds(30,40,170,170);
		bt_cafe.setBounds(220,40,170,170);
		bt_hos.setBounds(410,40,170,170);
		bt_bank.setBounds(600,40,170,170);
		bt_park.setBounds(130,220,170,170);
		bt_oil.setBounds(320,220,170,170);
		bt_movie.setBounds(510,220,170,170);
		bt_search.setBounds(700, 320, 70, 70);
		
		bt_rest.addActionListener(this);
		bt_cafe.addActionListener(this);
		bt_hos.addActionListener(this);
		bt_bank.addActionListener(this);
		bt_park.addActionListener(this);
		bt_oil.addActionListener(this);
		bt_movie.addActionListener(this);
		bt_search.addActionListener(this);
		
		add(bt_rest);
		add(bt_cafe);
		add(bt_hos);
		add(bt_bank);
		add(bt_park);
		add(bt_oil);
		add(bt_movie);		
		add(bt_search);
	}
	
	public void actionPerformed(ActionEvent ae){
		int selected=0;
		if(ae.getSource().equals(bt_search)){ 
			selected = 0;
			Main.Navi.con.removeAll();
			
			GUI_dest Dest= new GUI_dest();
			Dest.setBounds(0, 0, 800, 100);
			Main.Navi.con.add(Dest);
			
			Main.Navi.con.validate();
		}
		else{
			if(ae.getSource().equals(bt_rest)){
				selected = 201;
			}
			else if(ae.getSource().equals(bt_cafe)){
				selected = 202;
			}
			else if(ae.getSource().equals(bt_hos)){
				selected = 204;
			}
			else if(ae.getSource().equals(bt_bank)){
				selected = 205;
			}
			else if(ae.getSource().equals(bt_park)){
				selected = 206;
			}
			else if(ae.getSource().equals(bt_oil)){
				selected = 207;
			}
			else if(ae.getSource().equals(bt_movie)){
				selected = 211;
			}
			Main.Navi.con.removeAll();

			Main.Navi.selectedBuildings(selected);
			GUI_navi Navi = new GUI_navi("all", selected);

			Navi.setBounds(0, 0, 800, 100);
			Main.Navi.con.add(Navi);
			
			Main.Navi.con.validate();
		}
	}
}

